#include <iostream> 

using namespace std;
// using std::cout;
// using std::endl;

class new_type{
	private:
		void * data;
		char data_type;
	public:
		new_type(int i){
			data = (int*) new int(i);
			data_type='i';
		}

		new_type(float f){
			data = (float*) new float(f);
			data_type='f';
		}

		~new_type(){
			// Is it necessary to free data
			if (data_type=='i'){
				// cout << "deleting integer object" << endl;
				delete (int*) data;
			}
			else 
			 	// cout << "deleting float object" << endl;
				 delete (float*) data;
		}
	
	float get_value() const{
		if (data_type=='i')
				return *((int*) data);
		else
				return *((float*) data);
	}


	friend  float add(const new_type & v1, const new_type & v2);
};


float add(const new_type & v1, const new_type & v2){
	return v1.get_value()+v2.get_value();	
}


int main(){
	new_type v1(3), v2(4.0f);
	cout << add(v1,v2) << endl;
	cout << add(v1,5) << endl;
	cout << add(3.21f,5.10f) << endl;

}

